/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.meego.common.stats;

import com.meego.common.log.GA;
import java.lang.management.ManagementFactory;
import javax.management.MBeanServer;
import javax.management.ObjectName;

/**
 *
 * @author TueHM
 */
public class Status
  implements StatusMBean
{
  private final LatencyTracker stats = new LatencyTracker();

  public Status(String mbeanName) {
    MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
    try {
      mbs.registerMBean(this, new ObjectName(mbeanName));
    } catch (Exception e) {
      GA.monitor_stats.error(e);
    }
  }

  public void addNano(long nanoSec) {
    this.stats.addNano(nanoSec);
  }

    @Override
  public double getAvgLatency()
  {
    return this.stats.getAvgLatency();
  }

    @Override
  public long getLatencyPeak()
  {
    return this.stats.getLatencyPeak();
  }

    @Override
  public long getLatencyPeakTime()
  {
    return this.stats.getLatencyPeakTime();
  }

    @Override
  public long getOpCount()
  {
    return this.stats.getOpCount();
  }

    @Override
  public long getRPSPeak()
  {
    return this.stats.getRPSPeak();
  }

    @Override
  public long getRPSPeakTime()
  {
    return this.stats.getRPSPeakTime();
  }

    @Override
  public double getRecentLatencyMicros()
  {
    return this.stats.getRecentLatencyMicros();
  }

    @Override
  public long getTotalLatencyMicros()
  {
    return this.stats.getTotalLatencyMicros();
  }

    @Override
  public long getTotalOpsPerSec()
  {
    return this.stats.getTotalOpsPerSec();
  }
}
